//
//  HubuViewController.h
//  iHubu2
//
//  Created by hanshui on 12-10-31.
//  Copyright (c) 2012年 hanshui. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "NSURL+Download.h"
#import "DownloadManager.h"
#import "CommonWebServices.h"
#import "CommonSearchKeyWebServices.h"
#import "BookItem.h"
#import "DBUtil.h"
#import "BookConstants.h"
#import "ReaderViewController.h"
#import "TextReaderController.h"

@interface HubuViewController : UIViewController
<UIScrollViewDelegate, DownloadManagerDelegate,
CommonWebServicesProtocol, CommonSearchKeyWebServicesProtocol> {
    //ad begin
	UIScrollView *columnScrollView;
	UIPageControl *columnPageControl;
    NSMutableArray *columnViewControllers;
    BOOL columnPageControlUsed;
	//ad end
    
    
    NSString *lastApproval;//本地数据库的最新审批时间
    int remotePageIndex;//检查远程数据库的数据页码（每50项一页）
    
    BookItem *downloadBookItem;//下载的图书对象
    CGPoint downloadPadFromPoint;//下载来源地址
    int downloadButtonTag;//下载的按钮Tag
    BOOL isDownloading;//下载中（1）
    NSString *downloadingButtonTitle;
    UIView *downloadView;//下载中的试图面板
    UIProgressView *downloadProgressView;
    UILabel *downloadKB;
    UILabel *downloadTitle;
    DownloadManager *downloadManager;
    
    UIView *waitingViewContainer;//Waiting Pad
    UIImageView *waitingStateView;//State Image
    UIActivityIndicatorView *waitingView; //Waiting
    UILabel *waitingLabel;//Waiting Label;
    
    CommonWebServices *ws;
}

//ad begin
@property (nonatomic, retain) IBOutlet UIScrollView *columnScrollView;
@property (nonatomic, retain) IBOutlet UIPageControl *columnPageControl;
@property (nonatomic, retain) NSMutableArray *columnViewControllers;

@property (nonatomic, retain) IBOutlet UIButton *column0Button;
@property (nonatomic, retain) IBOutlet UIButton *column1Button;
@property (nonatomic, retain) IBOutlet UIButton *column2Button;
@property (nonatomic, retain) IBOutlet UIButton *column3Button;
@property (nonatomic, retain) IBOutlet UIButton *column4Button;
@property (nonatomic, retain) IBOutlet UILabel *columnButtonUnderLineLabel;


@property(nonatomic, assign) int downloadButtonTag;
@property(nonatomic, assign) BOOL isDownloading;
@property(nonatomic, retain) NSString *downloadingButtonTitle;
@property(nonatomic, retain) IBOutlet UIView *downloadView;
@property(nonatomic, retain) IBOutlet UIProgressView *downloadProgressView;
@property(nonatomic, retain) IBOutlet UILabel *downloadKB;
@property(nonatomic, retain) IBOutlet UILabel *downloadTitle;

@property(retain, nonatomic) IBOutlet UIView *waitingViewContainer;
@property(retain, nonatomic) IBOutlet UIImageView *waitingStateView;
@property(retain, nonatomic) IBOutlet UIActivityIndicatorView *waitingView;
@property(retain, nonatomic) IBOutlet UILabel *waitingLabel;

- (IBAction)columnPageControlValueChanged:(id)sender;
- (IBAction)columnButtonClick:(id)sender;
- (void)setColumnButtonStyle:(NSUInteger) columnIndex;

//检查服务器端新书
-(void)checkBookList;
//显示状态条信息
-(void)showStatePad:(NSString *)imageName msg:(NSString *)msg interval:(int)seconds;
//下载处理事件
- (void)downloadStart:(CGPoint)targetPoint bookItem:(BookItem *)downloadItem;
- (void)downloadStartNow;
//掩藏状态条信息
-(void)hiddenStatePad;
//恢复购买
-(IBAction)recoveryClick:(id)sender;

//切换到书架
-(IBAction)shelfClick:(id)sender;
@end
